
#include "iostream"
#include "vector"
#include "unordered_map"
#include "unordered_set"
#include "algorithm"
#include "string"
#include "list"
#include "string.h"

class OneLoop {
public:
    std::vector<std::vector<char>> map;
    int x = 0;
    int y = 0;
    int sx;
    int sy;
    void input() {
        int n;
        std::cin >> n;
        std::cin.get();
        for (int i = 0; i < n; ++i) {
            std::vector<char> line(n);
            for (int j = 0; j < n; ++j) {
                line[j] = std::cin.get();
                if(line[j]=='S'){
                    sx=j;
                    sy=i;
                }
            }
            map.push_back(line);
            std::cin.get();//换行
        }

        int cnt;
        std::cin >> cnt;
        std::cin.get();
        for (int i = 0; i < cnt; ++i) {
            std::string cmd;
            std::getline(std::cin, cmd);
#define Out 0
#define Diz 1
#define Get 2
#define Noi 3
            int state = Noi;
            x=sx;y=sy;
            for (auto c:cmd) {
                int ox = 0, oy = 0;
                if (c == 'R') {
                    ox = 1;
                } else if (c == 'U') {
                    oy = -1;
                } else if (c == 'L') {
                    ox = -1;
                } else if (c == 'D') {
                    oy = 1;
                }
                int fx = x + ox;
                int fy = y + oy;
                if (fx < 0 || fx >= n || fy < 0 || fy >= n) {
                    state = Out;
                    break;
                } else if (map[fy][fx] == '#') {
                    state = Diz;
                    break;
                } else if (map[fy][fx] == 'T') {
                    state = Get;
                    break;
                }
                x = fx;
                y = fy;
            }
            switch (state) {
                case Noi:
                    printf("I have no idea!");
                    break;
                case Get:
                    printf("I get there!");
                    break;
                case Diz:
                    printf("I am dizzy!");
                    break;
                case Out:
                    printf("I am out!");
                    break;
            }
            printf("\n");
        }
    }

    bool run(
    ) {
        input();

        return true;
    }
};

class Solution {
public:
    void run() {

        bool first = true;
        int a, b, c, d, e;
        std::cin >> a;
        while (a) {
            OneLoop l;
            if (!l.run()) {
//                return;
            }
            a--;
        }


    }
};

int main() {
//    bool cur_num= true;
    Solution().run();
    return 0;
}

